package leetcode.code1371;

import java.util.HashMap;
import java.util.Map;

import leetcode.IDebug;
import leetcode.helper.H;

public class Solution implements IDebug {

	public int findTheLongestSubstring(String s) {
		Map<Character, Integer> hash = new HashMap<>();
		hash.put('a', 0);
		hash.put('e', 1);
		hash.put('i', 2);
		hash.put('o', 3);
		hash.put('u', 4);
		Map<Integer, Integer> map = new HashMap<>();
		int record = 0;
		map.put(record, -1);
		int ans = 0;
		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if (hash.containsKey(c)) {
				record ^= 1 << hash.get(c);
			}
			if (map.containsKey(record)) {
				ans = Math.max(ans, i - map.get(record));
			} else {
				map.put(record, i);
			}
		}
		return ans;
	}

	@Override
	public void debug4() {
		H.compare(13, this.findTheLongestSubstring("eleetminicoworoep"));

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
